<template>
	<div>
		<template v-if="level === 'parent' && pSum >= 2">
			<span class="operation" @click="addSubCondition">&</span>
		</template>
		<template v-if="level === 'sub' && subkey === 0 && sum >= 2">
			<span class="operation" @click="addSubCondition">&</span>
		</template>
		<span class="operation" @click="DelCondition">
			<i class="iconfont icon-close-small" />
		</span>
	</div>
</template>
<script lang="ts">
import { Component, Prop, Emit, Vue } from 'vue-property-decorator'

@Component({
	name: 'ConditionOperation',
	components: {}
})
export default class extends Vue {
	@Prop() pkey!: number // 条件的key
	@Prop() subkey!: number // 子条件的key
	@Prop() itemKey!: number // 指标的key
	@Prop() item!: any
	@Prop() level!: string
	@Prop() sum!: number
	@Prop() pSum!: number

	@Emit('addSubCondition')
	private addSubCondition() {
		return {
			level: this.level,
			pkey: this.pkey,
			subkey: this.subkey,
			itemKey: this.itemKey,
			item: this.item
		}
	}
	@Emit('DelCondition')
	private DelCondition() {
		return {
			level: this.level,
			pkey: this.pkey,
			subkey: this.subkey,
			itemKey: this.itemKey,
			item: this.item
		}
	}
}
</script>
<style lang="scss" scoped>
.operation {
	margin-right: 5px !important;
}
</style>
